CCC to BIN, a PowerShell Tool
Copyright 2018 Joe Strosnider

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.



Purpose:
	To take .CCC cartridge dumps and convert them into a .BIN Format that can be understood by and imported to the CoCo SDC's built in flash storage for cartridge emulation.

Requirements:
	Windows with PowerShell 3.0 or better
	Set-ExecutionPolicy Unrestricted
	a .CCC File 16k or less in size
	A CoCo and CoCo SDC

Notes and Errata:
	This file will modify anything you give it with no regard to what kind of file you're giving it.
	The CoCoSDC (as of 4/15/2018) does not support cartridge images larger than 16k in size.

Usage:
	Run the script, either by double clicking it or right clicking and selecting "Run with PowerShell", depending on your system
	When prompted, select your source .CCC file.
	The program will modify the file, name it with a .BIN extension, and save it in the same path as the original.
	The program will automatically open an Explorer window with the file selected to help you find it.

	After you have your .BIN File, use a tool like CoCoDskUtil to add it to a .DSK image, then follow Ed Snyder's process for writing that file to a CoCoSDC Flash Bank
	https://sites.google.com/site/thezippsterzone/coco-sdc-pages/coco-sdc-writing-flash-banks

Theory of Operation:
	Hide the scripting window.
	Present a dialog box for the user to select a file.
		If the user doesn't select a file, tell them they goofed and quit.
	Get the length of the file in bytes.
	Convert that from a PSObject to a String.
	Modify the string to have only the required data.
	Modify the string to be in the proper hexadecimal format.
	Convert the string into byte array. (preamble)
	Define the postamble as a byte array.
	Pull the source file into a byte array.
	Prepend the preamble to the source byte array.
	Append the postamble to the source byte array.
	Save the final byte array to a new file, same name and location as original, but with a .BIN extension.
	Present the user an Explorer window with the created .BIN file highlighted.

